<template>
    <div>
        <h3>员工信息一览</h3>
        <table border="1" width="400" cellspacing="0" style="text-align">
            <thead>
                <tr><th>编号</th><th>姓名</th><th>电话</th><th>职位</th><th>生日</th><th>操作</th></tr>
            </thead>
            <tbody>
                <tr v-for="employee in page.list" :key="employee.id">
                    <td>{{employee.id}}</td>
                    <td>{{employee.name}}</td>
                    <td>{{employee.tel}}</td>
                    <td>{{employee.job}}</td>
                    <td>{{employee.birthday}}</td>
                    <td>
                        <a href="javascript:void(0)" @click="del(employee.id)" style="margin-right:5px">删除</a>
                        <a href="javascript:void(0)" @click="update(employee)">修改</a>
                    </td>
                </tr>
            </tbody>
        </table>

        <a v-for="n in page.pages" :key="n" style="margin-left:10px" href="javascript:void(0)" @click="pageClick(n)">{{n}}</a>
        <div>
            职位：<input type="text" v-model="param.job"><br>
            起始日期：<input type="date" v-model="param.startDate"><br>
            结束日期：<input type="date" v-model="param.endDate"><br>
            <input type="button" value="查询" @click="pageClick(1)">
        </div>
    </div>
</template>

<script>
export default {
    props:["page"],
    data(){
        return{
            param:{pageNO:1}
        }
    },
    methods:{
        pageClick(n){
            this.param.pageNO = n;
            this.$emit("page",this.param)
        },
        async del(employeeId){
            var info = await this.ajax.getSubmit("/project/employee/del",{id:employeeId});
            if(info == "ok"){
                this.$emit("page",{pageNO:1});
            }
        },
        update(employee){
            this.$emit("show",employee);
        }
    }
}
</script>

<style>

</style>